1 /****************************** Module Header ******************************\
2 * Module Name: RawAPI.h
3 * Project: CppCOMClient
4 * Copyright (c) Microsoft Corporation.
6 * This file demontrates the use of C/C++ and the COM APIs to automate a server.
7 * C/C++ Automation is much more difficult, but sometimes necessary to avoid
8 * overhead with MFC, or problems with #import. Basically, you work with such
9 * APIs as CoCreateInstance(), and COM interfaces such as IDispatch and IUnknown.
12 * http://support.microsoft.com/kb/216686
13 * http://support.microsoft.com/kb/238393
14 * http://support.microsoft.com/kb/216388
16 * This source is subject to the Microsoft Public License.
17 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
18 * All other rights reserved.
20 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
21 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
23 \***************************************************************************/
27 #pragma region Includes
28 #include <ole2.h> // OLE2 Definitions
34 * RawConsumeSTAComponent - Create and access a STA COM object by calling the
35 * COM API directly from C++.
39 * The prototype of a function that serves as the starting address for a
42 DWORD WINAPI
RawConsumeSTAComponent(LPVOID lpParam
);
47 * Automation helper function.
50 * DISPATCH_PROPERTYGET || DISPATCH_PROPERTYPUT || DISPATCH_PROPERTYPUTREF
54 * Holds the return value in a VARIANT
57 * The IDispatch interface
60 * The property/method name exposed by the interface
63 * The count of the arguments
68 * The AutoWrap() function simplifies most of the low-level details involved
69 * with using IDispatch directly. Feel free to use it in your own
70 * implementations. One caveat is that if you pass multiple parameters, they
71 * need to be passed in reverse-order.
75 * DISPATCH_METHOD, NULL, pDisp, L"call", 3, parm[2], parm[1], parm[0]);
77 HRESULT
AutoWrap(int autoType
, VARIANT
*pvResult
, IDispatch
*pDisp
,
78 LPOLESTR ptName
, int cArgs
...);